package com.wsl.sale.redis.dao;

import com.wsl.sale.redis.entity.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * @Author:wangshuliang
 * @Description:
 * @Date:Created in 22:48 2019/5/3
 * @Modified by:
 */
@Repository
public class PersonDao {
    @Autowired
    StringRedisTemplate stringRedisTemplate;
    @Resource(name="stringRedisTemplate")
    ValueOperations<String,String> valueOperations;
    @Autowired
    RedisTemplate<Object,Object> redisTemplate;
    @Resource(name="redisTemplate")
    ValueOperations<Object,Object> valOps;



    public void stringRedisTemplateDemo(){
        valueOperations.set("xx","yy");
    }

    public void save(Person person){
        valOps.set(person.getId(),person);
    }

    public String getString(){
        return valueOperations.get("xx");
    }

    public Person getPerson(){
        return (Person)valOps.get("1");
    }

}
